package com.ohos.connect.devicecloud.mqtt.modular.mqtt.provider;

import com.ohos.connect.devicecloud.mqtt.api.MqttApi;
import com.ohos.connect.devicecloud.mqtt.core.model.vo.MqttAccountVO;
import com.ohos.connect.devicecloud.mqtt.modular.mqtt.service.MqttService;
import org.eclipse.paho.mqttv5.common.MqttException;
import org.eclipse.paho.mqttv5.common.MqttMessage;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("mqttApi")
public class MqttApiProviderImpl implements MqttApi {

    @Resource
    private MqttService mqttService;

    @Override
    public MqttAccountVO getMqttAccountByDevice(String device) {
        return mqttService.getMqttAccountByDevice(device);
    }

    @Override
    public void sendMqttMessage(String topic, MqttMessage message) throws MqttException {
        mqttService.sendMqttMessage(topic,message);
    }
}
